package com.blrs.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.blrs.service.procure.procure.IPurchasingChangeRecordService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.blrs.common.annotation.Log;
import com.blrs.common.core.controller.BaseController;
import com.blrs.common.core.domain.AjaxResult;
import com.blrs.common.enums.BusinessType;
import com.blrs.domain.PurchasingChangeRecord;
import com.blrs.common.utils.poi.ExcelUtil;
import com.blrs.common.core.page.TableDataInfo;

/**
 * 采购管理变更记录Controller
 * 
 * @author ruoyi
 * @date 2023-10-18
 */
@RestController
@RequestMapping("/procure/record")
public class PurchasingChangeRecordController extends BaseController
{
    @Autowired
    private IPurchasingChangeRecordService purchasingChangeRecordService;

    /**
     * 查询采购管理变更记录列表
     */
    //@PreAuthorize("@ss.hasPermi('procure:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(PurchasingChangeRecord purchasingChangeRecord)
    {
        startPage();
        List<PurchasingChangeRecord> list = purchasingChangeRecordService.selectPurchasingChangeRecordList(purchasingChangeRecord);
        return getDataTable(list);
    }

    /**
     * 导出采购管理变更记录列表
     */
    //@PreAuthorize("@ss.hasPermi('procure:record:export')")
    @Log(title = "采购管理变更记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PurchasingChangeRecord purchasingChangeRecord)
    {
        List<PurchasingChangeRecord> list = purchasingChangeRecordService.selectPurchasingChangeRecordList(purchasingChangeRecord);
        ExcelUtil<PurchasingChangeRecord> util = new ExcelUtil<PurchasingChangeRecord>(PurchasingChangeRecord.class);
        util.exportExcel(response, list, "采购管理变更记录数据");
    }

    /**
     * 获取采购管理变更记录详细信息
     */
    //@PreAuthorize("@ss.hasPermi('procure:record:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(purchasingChangeRecordService.selectPurchasingChangeRecordById(id));
    }

    /**
     * 新增采购管理变更记录
     */
    //@PreAuthorize("@ss.hasPermi('procure:record:add')")
    @Log(title = "采购管理变更记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PurchasingChangeRecord purchasingChangeRecord)
    {
        return toAjax(purchasingChangeRecordService.insertPurchasingChangeRecord(purchasingChangeRecord));
    }

    /**
     * 修改采购管理变更记录
     */
    //@PreAuthorize("@ss.hasPermi('procure:record:edit')")
    @Log(title = "采购管理变更记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PurchasingChangeRecord purchasingChangeRecord)
    {
        return toAjax(purchasingChangeRecordService.updatePurchasingChangeRecord(purchasingChangeRecord));
    }

    /**
     * 删除采购管理变更记录
     */
    //@PreAuthorize("@ss.hasPermi('procure:record:remove')")
    @Log(title = "采购管理变更记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(purchasingChangeRecordService.deletePurchasingChangeRecordByIds(ids));
    }
}
